<?php

class Transfer extends AppModel {
	var $name = 'Transfer';

	var $useTable = 'mnhis_transfer';

	protected $fields = array(
		'id' => array('name' => 'ID'),
		'fk_offer_id' => array('name' => 'Ponuka', 'reference' => array('model' => 'Market', 'field' => 'description', 'default' => 'Žiadna')),
		'fk_demand_id' => array('name' => 'Dopyt', 'reference' => array('model' => 'Market', 'field' => 'description', 'default' => 'Žiadny')),
		'commission' => array('name' => 'Provízia'),
		'referenced' => array('name' => 'Referenčný obchod', 'evaluation' => array('0' => 'nie', '1' => 'áno', 'default' => 'nie')),
	);
	
	var $belongsTo = array(
		'Offer' => array(
			'className' => 'Market',
			'foreignKey' => 'fk_offer_id',
		),
		'Demand' => array(
			'className' => 'Market',
			'foreignKey' => 'fk_demand_id',
		),
	);

	var $validate = array(
		'fk_offer_id' => array(
			'rule' => array('comparison', '>', 0),
			'message' => 'Musíte vybrať ponuku'
		),
	);
	
	var $relations = array(
		'Commission' => array(
			'fk_transfer_id' => array(
				'field' => 'id',
				'message_one' => 'Depozit: ###PLACEHOLDER### musí byť najprv zmazaný alebo priradený inému obratu',
				'message_more' => 'Depozity: ###PLACEHOLDER### musia byť najprv zmazané alebo priradené iným obratom',
			),
		),
	);
}

?>